-
-
Notifications
You must be signed in to change notification settings - Fork 514
Add support for PHP 8.4 Lazy Objects with configuration flag #2840
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
421e842
to
cb0b5f6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds support for PHP 8.4 Lazy Objects with a configuration flag, implementing native lazy loading functionality as an alternative to the existing proxy mechanisms. The implementation borrows from the Doctrine ORM approach and introduces a new PropertyAccessor system to handle property access uniformly across different scenarios.
- Introduces native lazy objects support for PHP 8.4+ as a replacement for existing proxy systems
- Replaces the reflection-based property access with a new PropertyAccessor architecture
- Adds comprehensive test coverage for property hooks and lazy object functionality
Reviewed Changes
Copilot reviewed 46 out of 46 changed files in this pull request and generated 1 comment.
Show a summary per file
File | Description |
---|---|
lib/Doctrine/ODM/MongoDB/Configuration.php | Adds configuration methods for enabling native lazy objects |
lib/Doctrine/ODM/MongoDB/Proxy/Factory/NativeLazyObjectFactory.php | New factory for creating native lazy objects in PHP 8.4+ |
lib/Doctrine/ODM/MongoDB/Mapping/PropertyAccessors/*.php | New PropertyAccessor system replacing direct reflection usage |
lib/Doctrine/ODM/MongoDB/Mapping/ClassMetadata.php | Updated to use PropertyAccessor instead of reflection fields |
lib/Doctrine/ODM/MongoDB/UnitOfWork.php | Updated for native lazy object support and PropertyAccessor usage |
tests/Documents84/ | New test documents for PHP 8.4 property hooks functionality |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
lib/Doctrine/ODM/MongoDB/Mapping/PropertyAccessors/ObjectCastPropertyAccessor.php
Show resolved
Hide resolved
… its scanned by several tests
Never implemented in ODM
lib/Doctrine/ODM/MongoDB/Mapping/PropertyAccessors/PropertyAccessorFactory.php
Show resolved
Hide resolved
lib/Doctrine/ODM/MongoDB/Mapping/PropertyAccessors/RawValuePropertyAccessor.php
Show resolved
Hide resolved
if ($this->dm->getConfiguration()->isNativeLazyObjectsEnabled()) { | ||
return; | ||
} | ||
|
||
$this->markTestSkipped('Property hooks require native lazy objects to be enabled.'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did phpcs ask for the early return? I find the following easier to read...
if ($this->dm->getConfiguration()->isNativeLazyObjectsEnabled()) { | |
return; | |
} | |
$this->markTestSkipped('Property hooks require native lazy objects to be enabled.'); | |
if ($this->dm->getConfiguration()->isNativeLazyObjectsEnabled()) { | |
$this->markTestSkipped('Property hooks require native lazy objects to be enabled.'); | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, PHPCS. I hate this rule. We need a way to disable it when the condition only contains 1 statement.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The EarlyExit sniff supports the ignoreStandaloneIfInScope
, ignoreOneLineTrailingIf
, and ignoreTrailingIfWithOneInstruction
options that allow us to customise this. I believe the ignoreTrailingIfWithOneInstruction
option allows this kind of usage, but I also don't mind enabling all of them.
tests/Doctrine/ODM/MongoDB/Tests/Mapping/AbstractAnnotationDriverTestCase.php
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 49 out of 49 changed files in this pull request and generated 2 comments.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
lib/Doctrine/ODM/MongoDB/Mapping/PropertyAccessors/ObjectCastPropertyAccessor.php
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested in one of my projects, works fine with readonly properties and such. Great work!
Summary
Shamelessly copied from the brilliant work of Benjamin Eberlei on ORM: